using Perfect.Marshal;
using System.Xml;

namespace editor
{
namespace cfg.fight
{
[System.Serializable]
public  class Normal : MainAttr
 {



    public const int TYPE_ID = 1956781585;

    public override int GetTypeId() {
        return TYPE_ID;
    }


    public override void MarshalCompatible(Perfect.Marshal.Octets os) {
        os.WriteSize(7);
        os.WriteSize(Tag.INT | (1 << Tag.TAG_SHIFT));  os.WriteInt((int)type);  
         os.WriteSize(Tag.STRING | (2 << Tag.TAG_SHIFT));  os.WriteString(name);  
         os.WriteSize(Tag.BOOL | (8 << Tag.TAG_SHIFT));  os.WriteBool(isInteger);  
         os.WriteSize(Tag.BOOL | (3 << Tag.TAG_SHIFT));  os.WriteBool(syncToClient);  
         os.WriteSize(Tag.BOOL | (4 << Tag.TAG_SHIFT));  os.WriteBool(broadcast);  
         os.WriteSize(Tag.LIST | (5 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_list_cfg_fight_AttributeType(percentMinors,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         os.WriteSize(Tag.LIST | (6 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_list_cfg_fight_AttributeType(valueMinors,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         
    }

    public override void UnmarshalCompatible(Perfect.Marshal.Octets os) {
        for (int _var_num_ = os.ReadSize(); _var_num_-- > 0; ) {
            int _id_ = os.ReadSize();
            switch (_id_)
            {
            case (Tag.INT | (1 << Tag.TAG_SHIFT)):   type = (cfg.fight.AttributeType)(os.ReadInt()); break;  
             case (Tag.STRING | (2 << Tag.TAG_SHIFT)):   name = os.ReadString(); break;  
             case (Tag.BOOL | (8 << Tag.TAG_SHIFT)):   isInteger = os.ReadBool(); break;  
             case (Tag.BOOL | (3 << Tag.TAG_SHIFT)):   syncToClient = os.ReadBool(); break;  
             case (Tag.BOOL | (4 << Tag.TAG_SHIFT)):   broadcast = os.ReadBool(); break;  
             case (Tag.LIST | (5 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); percentMinors = cfg.Extensions.unmarshal_compatible_list_cfg_fight_AttributeType(os); os = _oldOs; break; }   
             case (Tag.LIST | (6 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); valueMinors = cfg.Extensions.unmarshal_compatible_list_cfg_fight_AttributeType(os); os = _oldOs; break; }   
             
            default: Tag.SkipUnknownField(_id_, os); break;
            }
         }
    }
    public override void MarshalXml(XmlWriter ele)
    {
        ele.WriteAttributeString("type", "Normal");
        ele.WriteStartElement("type"); ele.WriteAttributeString("id", "1"); ele.WriteEnum(type); ele.WriteEndElement();
         ele.WriteStartElement("name"); ele.WriteAttributeString("id", "2"); ele.WriteString2(name); ele.WriteEndElement();
         ele.WriteStartElement("isInteger"); ele.WriteAttributeString("id", "8"); ele.WriteBool(isInteger); ele.WriteEndElement();
         ele.WriteStartElement("syncToClient"); ele.WriteAttributeString("id", "3"); ele.WriteBool(syncToClient); ele.WriteEndElement();
         ele.WriteStartElement("broadcast"); ele.WriteAttributeString("id", "4"); ele.WriteBool(broadcast); ele.WriteEndElement();
         ele.WriteStartElement("percentMinors"); ele.WriteAttributeString("id", "5"); cfg.Extensions.xml_marshal_list_cfg_fight_AttributeType(percentMinors,ele); ele.WriteEndElement();
         ele.WriteStartElement("valueMinors"); ele.WriteAttributeString("id", "6"); cfg.Extensions.xml_marshal_list_cfg_fight_AttributeType(valueMinors,ele); ele.WriteEndElement();
         
    }

    public override void UnmarshalXml(XmlElement ele)
    {
        foreach (XmlElement e in ele.GetChildren())
        {
            if (int.TryParse(ele.GetAttribute("id"), out var _id_))
            {
                switch (_id_)
                {
                case 1:  type = ele.ReadEnum<cfg.fight.AttributeType>(); break; 
                 case 2:  name = ele.ReadString2(); break; 
                 case 8:  isInteger = ele.ReadBool(); break; 
                 case 3:  syncToClient = ele.ReadBool(); break; 
                 case 4:  broadcast = ele.ReadBool(); break; 
                 case 5:  percentMinors = cfg.Extensions.xml_unmarshal_list_cfg_fight_AttributeType(ele); break; 
                 case 6:  valueMinors = cfg.Extensions.xml_unmarshal_list_cfg_fight_AttributeType(ele); break; 
                 
                default: break;
                }
            }
            else
            {
                switch (e.Name)
                {
                case "type":  type = ele.ReadEnum<cfg.fight.AttributeType>(); break; 
                 case "name":  name = ele.ReadString2(); break; 
                 case "is_integer":  isInteger = ele.ReadBool(); break; 
                 case "sync_to_client":  syncToClient = ele.ReadBool(); break; 
                 case "broadcast":  broadcast = ele.ReadBool(); break; 
                 case "percent_minors":  percentMinors = cfg.Extensions.xml_unmarshal_list_cfg_fight_AttributeType(ele); break; 
                 case "value_minors":  valueMinors = cfg.Extensions.xml_unmarshal_list_cfg_fight_AttributeType(ele); break; 
                 
                default: break;
                }
            }
        }
    }
}
}
}
